#include <errno.h>  // for errno
#ifndef _WIN32
#include <unistd.h> // for send
#endif

namespace unix_Errno {
#ifndef _WIN32
int unsafe_errno_read(int sock, void* data, int data_size) {
    if (send(sock, data, data_size, 0) != data_size) {
        // 'send' can be successful even if not all data was sent
        if (errno == 1) { // An undefined value may be read from 'errno'
            return 0;
        }
    }
    return 1;
}

int unsafe_errno_read(int sock, void* data, int data_size) {
    if (send(sock, data, data_size, 0) != data_size) {
        int err = errno;
        // warning if 'AllowErrnoReadOutsideConditionExpressions' is false
        // no warning if 'AllowErrnoReadOutsideConditionExpressions' is true
    }
    return 1;
}
#endif

}